;INLINE UInt8 BilinearQuadA8(
;                UInt8* color0, UInt8* color1, UInt32 u_8, UInt32 v_8)
;{
;    UInt32 pm3_16 = u_8 * v_8;
;    UInt32 pm2_16 = (u_8<<8) - pm3_16;
;    UInt32 pm1_16 = (v_8<<8) - pm3_16;
;    UInt32 pm0_16 = 0x0000FFFF - pm1_16 - pm2_16 - pm3_16;
;
;    return (UInt8)((pm0_16 * color0[0] + pm2_16*color0[1]
;            + pm1_16 * color1[0] + pm3_16 * color1[1])>>16);
;}

;R0 = Pixel
;R1 = color0
;R2 = color1
;R3 = u_8
;R4 = v_8

;R5 = pm3_8
;lr = 0x00FF00FF

        AREA sample, CODE, READONLY
   EXPORT  BilinearQuadA8
BilinearQuadA8


	stmfd	sp!, {r4, r5, r6, r7, lr}

	mul	    lr, r3, r2

	ldrb	r4, [r1, #1]	; zero_extendqisi2
	mov	    lr, lr, lsr #8
	ldrb	r5, [r0, #1]	; zero_extendqisi2
	rsb	    ip, lr, r2

	mul	    r7, ip, r5
	mul	    r6, lr, r4

	rsb	    r3, lr, r3
	rsb	    ip, r3, #0
	rsb	    ip, r2, ip
	ldrb	r2, [r1, #0]	; zero_extendqisi2
	ldrb	r1, [r0, #0]	; zero_extendqisi2

	add	    ip, ip, #256
	mla	    r0, r3, r2, r6
	mla	    r3, ip, r1, r7

	add	    r1, r0, r3
	mov	    r0, r1, lsr #8
    and	    r0, r0, #255

	ldmfd	sp!, {r4, r5, r6, r7, pc}

    END

